<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App;

class UserLevel extends Model
{

  protected $with = ['users_level_translations'];

  public function getTranslation($field = '', $lang = false){
      $lang = $lang == false ? App::getLocale() : $lang;
      $users_level_translations = $this->users_level_translations->where('lang', $lang)->first();
      return $users_level_translations != null ? $users_level_translations->$field : $this->$field;
  }

  public function users_level_translations(){
    return $this->hasMany(UserLevelTranslation::class);
  }

}
